package com.example.share_doc.controller;

import com.example.share_doc.entity.Message;
import com.example.share_doc.service.MessageService;
import com.example.share_doc.util.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/message")
@Tag(name = "公告接口")
public class MessageController {

    private MessageService messageService;

    @GetMapping("/latest")
    public R messageLatest() {
        Message message = messageService.messageLatest();
        return R.success(message);
    }

    @PostMapping("/updateMessage")
    public R updateMessage(@RequestBody Message message) {
        messageService.updateMessage(message);
        return R.success(null);
    }

    @PostMapping("/deleteMessageList")
    public R deleteMessageList(List<String> messageIdList){
        messageService.deleteMessageList(messageIdList);
        return R.success(null);
    }

}
